package com.binarysorttree;

import java.util.HashMap;
import java.util.Map;

public class BinarySortTreeDemo {
    public static void main(String[] args) {
        int[] arr = {7,3,10,12,5,1,9,2};
        BinarySortTree binarySortTree = new BinarySortTree();
        for (int n :arr){
            binarySortTree.add(new Node(n));
        }
        binarySortTree.infixOrder();
        Map<String,Node> map = new HashMap<>();
        System.out.println("删除结点后:");
        binarySortTree.deleteNode (12,map);
        binarySortTree.deleteNode (7,map);
        binarySortTree.deleteNode(5,map);
        binarySortTree.deleteNode (3,map);
        binarySortTree.deleteNode(10,map);
        binarySortTree.deleteNode (2,map);
        binarySortTree.deleteNode (9,map);
        binarySortTree.deleteNode (1,map);
        binarySortTree.infixOrder();
    }
}
